package reflect;

import reflect.annotations.AutoRunClass;

import java.io.File;
import java.io.FileFilter;
import java.net.URISyntaxException;

/**
 * 调用与当前类 Test10 与同一个包中被注解@AutoRunClass标注的类中，被@AutoRunMethod标注的方法
 * 指定次，次数由方法上注解中的参数决定
 */
public class Test10 {
    public static void main(String[] args) throws URISyntaxException, ClassNotFoundException, InstantiationException, IllegalAccessException {
        String pack = Test10.class.getPackage().getName();
        File dir = new File(Test10.class.getResource(".").toURI());
        if(dir.isDirectory()){
            FileFilter filter = new FileFilter() {
                @Override
                public boolean accept(File pathname) {
                    String name = pathname.getName();
                    boolean bo = name.endsWith(".class");
                    return bo;
                }
            };
            File[] subs = dir.listFiles(filter);
            for(File sub : subs) {
                String filename = sub.getName();
                String className = filename.replace(".class","");
                Class cls = Class.forName(pack+"."+className);
                if(cls.isAnnotationPresent(AutoRunClass.class)){

                }

            }
        }
    }
}
